﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Weapon : MonoBehaviour
{
    //用于实例化的子弹对象
    public GameObject bullet;

    //外部决定有几个发射位置 
    public Transform[] shootPos;

    private TankBase fatherObj;

    public void SetFather(TankBase obj)
    {
        fatherObj = obj;
    }
    
    public void Fire()
    {
        for (int i=0; i<shootPos.Length; i++)
        {
            GameObject obj = Instantiate(bullet, shootPos[i].position, shootPos[i].rotation);
            //控制子弹做什么
            Bullet bulletObj = obj.GetComponent<Bullet>();
            bulletObj.SetFather(fatherObj);
        }
    }
}
